package com.fjnldx.mes.controller.scddglController;

import com.fjnldx.mes.domain.domainReq.ArrayReq;
import com.fjnldx.mes.domain.domainReq.DdbhArray;
import com.fjnldx.mes.domain.domainReq.DeleteReq;
import com.fjnldx.mes.domain.domainReq.DingerReq;
import com.fjnldx.mes.domain.domainRes.Result;
import com.fjnldx.mes.domain.pojo.MesNewscjhInfo;
import com.fjnldx.mes.domain.pojo.Order;
import com.fjnldx.mes.domain.pojo.OrderSec;
import com.fjnldx.mes.service.scddglService.SecService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/order")
@Api(value = "生产订单管理", tags = "生产订单管理")
public class SecController {
    @Resource
    SecService secService;

    @PostMapping("/dd/queryDd")
    @ApiOperation(value = "查询订单", notes = "生产订单管理-订单管理-订单查询")
    public Result conFc1(@RequestBody Order data) throws Exception {
        return secService.queryOrder(data);
    }

    @PostMapping("/dd/deleteDd")
    @ApiOperation(value = "删除订单", notes = "生产订单管理-订单管理-删除订单")
    public Result conFc2(@RequestBody ArrayReq arrayReq) throws Exception {
        return secService.deleteOrder(arrayReq);
    }

    @PostMapping("/dd/updateDd")
    @ApiOperation(value = "更新订单", notes = "生产订单管理-订单管理-更新订单")
    public Result conFc3(@RequestBody Order data) throws Exception {
        return secService.updateOrder(data);
    }

    @PostMapping("/dd/insertDd")
    @ApiOperation(value = "新增订单", notes = "生产订单管理-订单管理-新增订单")
    public Result conFc4(@RequestBody Order data) throws Exception {
        return secService.insertOrder(data);
    }

    @PostMapping("/ddSec/queryDdSec")
    @ApiOperation(value = "二级订单查询", notes = "生产订单管理-订单管理-合并订单-二级订单查询")
    public Result conFc8(@RequestBody OrderSec data) throws Exception {
        return secService.queryOrderSec(data);
    }

    @PostMapping("/ddSec/updateDdSec")
    @ApiOperation(value = "二级订单更新", notes = "生产订单管理-订单管理-合并订单-二级订单更新")
    public Result conFc9(@RequestBody OrderSec data) throws Exception {
        return secService.updateOrderSec(data);
    }

    @PostMapping("/ddSec/insertDdSec")
    @ApiOperation(value = "从一级订单中选择新增二级订单", notes = "从一级订单中选择新增二级订单")
    public Result insertOrderSec(@RequestBody ArrayReq arrayReq) throws Exception {
        return secService.insertOrderSec(arrayReq);
    }

    @PostMapping("/ddSec/deleteDdSec")
    @ApiOperation(value = "删除二级订单", notes = "生产订单管理-订单管理-合并订单-二级订单删除回到一级")
    public Result conFc10(@RequestBody ArrayReq arrayReq) throws Exception {
        return secService.deleteOrderSec(arrayReq);
    }


    @PostMapping("/ddSec/mergeDd")
    @ApiOperation(value = "合并订单", notes = "生产订单管理-订单管理-合并订单")
    public Result conFc7(@RequestBody DdbhArray array) throws Exception {
        return secService.mergeOrder(array);
    }

    //=========================
    @PostMapping("/scjh/queryScjh")
    @ApiOperation(value = "生产计划查询", notes = "生产计划查询")
    public Result queryScjh(@RequestBody MesNewscjhInfo data) throws Exception {
        return secService.queryScjh(data);
    }

    @PostMapping("/scjh/queryScjhSec")
    @ApiOperation(value = "生产计划查询-二级", notes = "生产计划查询-二级")
    public Result queryScjhSec(@RequestBody MesNewscjhInfo data) throws Exception {
        return secService.queryScjhSec(data);
    }

    @PostMapping("/scjh/queryDingErByPzAndGongxu")
    @ApiOperation(value = "根据品种工序进行定额查询", notes = "根据品种工序进行定额查询")
    public Result queryDingErByPzAndGongxu(@RequestBody DingerReq data) throws Exception {
        return secService.queryDingErByPzAndGongxu(data);
    }

    @PostMapping("/scjh/deleteScjh")
    @ApiOperation(value = "删除生产计划", notes = "删除生产计划")
    public Result deleteScjh(@RequestBody DeleteReq data) throws Exception {
        return secService.deleteScjh(data.getArray());
    }

    @PostMapping("/scjh/insertScjh")
    @ApiOperation(value = "新增生产计划", notes = "新增生产计划")
    public Result insertScjh(@RequestBody MesNewscjhInfo data) throws Exception {
        return secService.insertScjh(data);
    }

    @PostMapping("/scjh/upDateScjh")
    @ApiOperation(value = "更新生产计划", notes = "更新生产计划")
    public Result upDateScjh(@RequestBody MesNewscjhInfo data) throws Exception {
        return secService.upDateScjh(data);
    }
}
